package cn.yitun.chat.yitunserverimcore.general.main.push.group;

import cn.yitun.chat.yituncommonmessage.push.PushMessage;
import cn.yitun.chat.yitunservercommonlib.constant.ActionTypeConstant;
import cn.yitun.chat.yitunservercommonlib.enums.control.push.group.GroupCategoryPushMethodEnum;
import cn.yitun.chat.yitunserverimcore.bridge.net.WriteHandler;
import cn.yitun.chat.yitunserverimcore.general.common.util.PushMessageBuild;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 群分组相关推送
 * Date 2019-01-27 21:43:21<br>
 * Description
 * 
 * @author yitun<br>
 * @since 1.1
 */
@Service
public class GroupCategoryPush {
	//1.2.202
	final String action = ActionTypeConstant.GROUP_CATEGORY_ACTION_PUSH;

	@Resource
	WriteHandler writeHandler;

	/**
	 * 添加
	 * @param key
	 * @param categoryId
	 * @param userId
	 */
	public void pushAdd(Long key, Long categoryId, Long userId) {
		String method = GroupCategoryPushMethodEnum.ADD.getMethod();
		PushMessage message = PushMessageBuild.build(key, action, method);
		message.bodyPut("categoryId", categoryId);
		writeHandler.push(userId, message);
	}

//	/**
//	 * 列表
//	 * @param key
//	 * @param list
//	 * @param userId
//	 */
//	public void pushSetList(Long key, List<GroupCategoryVo> list, Long userId) {
//		String method = GroupCategoryPushMethodEnum.ADD.getMethod();
//		PushMessage message = PushMessageBuild.build(key, action, method);
//		message.bodyPut("list", list);
//		writeHandler.push(userId, message);
//	}

	/**
	 * 编辑名称
	 * @param key
	 * @param categoryId
	 * @param name
	 * @param userId
	 */
	public void pushUpdateName(Long key, Long categoryId, String name, Long userId) {
		String method = GroupCategoryPushMethodEnum.UPDATE_NAME.getMethod();
		PushMessage message = PushMessageBuild.build(key, action, method);
		message.bodyPut("categoryId", categoryId);
		message.bodyPut("name", name);
		writeHandler.push(userId, message);
	}

	/**
	 * 编辑排序
	 * @param key
	 * @param userId
	 */
	public void pushUpdateRank(Long key, Long userId) {
		String method = GroupCategoryPushMethodEnum.UPDATE_RANK.getMethod();
		PushMessage message = PushMessageBuild.build(key, action, method);
		writeHandler.push(userId, message);
	}

	/**
	 * 删除
	 * @param key
	 * @param categoryId
	 * @param userId
	 */
	public void pushDelete(Long key, Long categoryId, Long userId) {
		String method = GroupCategoryPushMethodEnum.REMOVE.getMethod();
		PushMessage message = PushMessageBuild.build(key, action, method);
		message.bodyPut("categoryId", categoryId);
		writeHandler.push(userId, message);
	}
}
